<template>
    <div id="container">
    </div>
</template>
  
<script>
import AMapLoader from '@amap/amap-jsapi-loader';

export default {

    props: {
        position: {
            type: Array,
            default: [0, 0]
        }
    },
    name: 'Map',

    data() {
        return {
            infoWindow: null,
            map: null,// 存储上述坐标点
        }
    },

    mounted() {
        this.initMap();
        //.log(this.position)
    },

    methods: {
        initMap() {
            AMapLoader.load({
                key: "0a72a0fa26c13e8fa8581cbe701c0620",             // 申请好的Web端开发者Key，首次调用 load 时必填
                version: "2.0",      // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
                plugins: ['AMap.Scale'],       // 需要使用的的插件列表，如比例尺'AMap.Scale'等
            }).then((AMap) => {
                this.map = new AMap.Map("container", {  //设置地图容器id
                    viewMode: "3D",    //是否为3D地图模式
                    zoom: 10,           //初始化地图级别
                    center: this.position, //初始化地图中心点位置
                });

                this.infoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -30) });

                var marker = new AMap.Marker({
                    position: this.position,
                    map: this.map
                })

            }).catch(e => {
                // //.log(e);
            });
        },

        markerClick(e) {
            this.infoWindow.setContent(e.target.content);
            this.infoWindow.open(this.map, e.target.getPosition());
        }
    },
};
</script>

<style lang="less" scoped>
#container {
    width: 100%;
    height: 200px;
}

.t_card_main {
    width: 100%;
    height: 100%;
}
</style>

